// 测试核销功能
const config = require('./mini/config/api.js');
const request = require('./mini/libs/request.js');

async function testUseTicket() {
    try {
        console.log('开始测试核销功能...');
        
        // 模拟登录（这里需要实际的登录逻辑）
        const loginResponse = await request.post(`${config.baseUrl}/v1/login`, {
            data: {
                phone: '13800138000',
                password: '123456'
            }
        });
        
        if (loginResponse.code !== 1) {
            console.error('登录失败:', loginResponse.msg);
            return;
        }
        
        console.log('登录成功');
        
        // 测试核销码
        const testCode = 'TEST123456'; // 这里需要替换为实际的核销码
        
        const response = await request.post(`${config.baseUrl}/v1/biz-goods-ticket/useTicket`, {
            needAuth: true,
            data: {
                code: testCode
            }
        });
        
        console.log('核销结果:', response);
        
        if (response.code === 1) {
            console.log('✅ 核销成功');
            console.log('核销信息:', response.data);
        } else {
            console.log('❌ 核销失败:', response.msg);
        }
        
    } catch (error) {
        console.error('测试失败:', error.message);
    }
}

// 运行测试
if (require.main === module) {
    testUseTicket();
}

module.exports = {
    testUseTicket
}; 